Can Blazor Webassembly use EntityFramework without the hosting option?

您所在的位置:网站首页 database ranking Can Blazor Webassembly use EntityFramework without the hosting option?

Can Blazor Webassembly use EntityFramework without the hosting option?

#Can Blazor Webassembly use EntityFramework without the hosting option?| 来源: 网络整理| 查看: 265

Hello everyone!

Regarding my previous question How can I use Blazor for my project? I used the last days to play around with Azure and Blazor (what a rhyme).

I like both so far but I have a question which I could not find an answer: Can Blazor Webassembly use the Azure SQL Database if it is not hosted? ("hosted" means the option if you setup a new Blazor Webassembly project in Visual Studio).

What I did

I created a new Blazor Webassembly app by following this tutorial Secure an ASP.NET Core Blazor WebAssembly standalone app with Azure Active Directory B2C and succeeded. I created a Azure SQL Database by using the SQL Server Object Explorer from Visual Studio (that basically opens a browser to create it in Azure). After the creation I was not able to see it in the SQL Server Object Explorer . After a search I proceeded with the next step. I used that tutorial Add a connection to Azure SQL Database to connect the SQL database. (I had a issue to apply the firewall rules because the database was not public available in the network section). But after successfully adding it I was not able to proceed the Add migration part. There was no dbContext to find. After some search I found that article: Cannot connect to SQL database using Blazor and Entity Framework

The article is a bit old, but is this still valid? Should Blazor Webassembly not use the Entity Framework? If this is not longer valid, how can I implement the Azure SQL Database as Connected Service inside my solution? I followed several articles and created a simple model

ProductDto.cs

#nullable disable namespace BlazorTest.Shared { internal class ProductDto { public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } public float? Price { get; set; } } }

and a context ProductContext.cs

using Microsoft.EntityFrameworkCore; namespace BlazorTest.Shared.Data { internal class ProductContext : DbContext { internal DbSet


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3